import { reqUserLogin } from "@/utils/service.js";
import { dealResult } from "@/utils/common.js";
import $ from 'jquery';

export default {
    name: 'login',
    data() {
        return {
            formInline: {
                username: '',
                password: '',
            },
            rules: {
                username: [{ required: true, message: '请输入用户名!', trigger: 'blur' }],
                password: [{ required: true, message: '请输入密码!', trigger: 'blur' }],
            },
        }
    },
    mounted() {},
    created() {},
    components: {},
    methods: {
        submitForm(formName) {
            let that = this;
            this.$refs[formName].validate(valid => {
                if (valid) {
                    let formInline = that.formInline;
                    if (formInline.username == "cy" && formInline.password == "123456") {
                        this.$message({
                            type: "success",
                            message: "成功了"
                        })
                        that.$router.push('/');
                    } else {
                        this.$message({
                            type: "error",
                            message: "账号或密码错误,请重新输入!"
                        })
                    }




                    // let param = {
                    //     ...formInline
                    // };
                    // reqUserLogin(param, data => {
                    //     if (data.result == "1") {
                    //         that.$message.success('登录成功!');
                    //         let info = data.data;
                    //         if (info && info.length > 0) {
                    //             localStorage.setItem('muLinUser', JSON.stringify(info[0]));
                    //         }
                    //         that.$router.push('/');
                    //     }
                    //     dealResult(data);
                    // });
                } else {
                    return false;
                }
            });
        },
    }
}